<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Monk
 *
 * @author 耿鸿飞 <eoe2005@gmail.com>
 */
class Monk {
    /**
     *
     * @var type 
     */
    private $data = array();
    
    private $_dir ;
    private $_root;
    
    private $_config;
    
    private static $_self = false;
    
    public function __get($name){
        switch ($name){
            case 'log':
                if(!isset($this->data['log'])){
                    $this->data['log'] = new Log;
                }
                break;
            case 'session':
                break;
            case 'user':
                break;
            case 'imgage':
                $this->data['image'] = new Image;
                break;
        }
    }
    
    public static function app(){
        if(self::$_self === false){
            self::$_self = new Monk;
        }
        
        return self::$_self;
    }
    private function __construct() {
        $this->_dir = realpath(dirname(__FILE__));
        spl_autoload_register(array($this,'__autoloadClass'));
    }
    public function __autoloadClass($className){
        if(file_exists($this->_dir.'/libs/'.$className.'.class.php')){
            include $this->_dir.'/libs/'.$className.'.class.php';
        }else{
            
        }
    }
    public function run($config = false){
        if($config){
            $this->_config = $config;
        }
    }
}

?>
